from api.ihrm_emp_manage_api import IHRMEmpManageApi
from common.db_util import DBUtil
from common.token_util import TokenUtil


class EmpUtil:


    @classmethod
    def get_emp_id(cls):
        #先获取token
        token = TokenUtil.get_token()
        #先从数据库删除这个手机号18957756667
        del_sql = f"DELETE from bs_user WHERE mobile ='18957756667';"
        DBUtil.uid_db(del_sql)
        #然后做添加员工
        body = {
            "username": "小猪佩奇",
            "mobile": "18957756667",
            "workNumber": "22"
        }
        resp = IHRMEmpManageApi.add_emp_api(token, body)
        print(resp.json())
        #获取员工id
        emp_id = resp.json().get("data").get("id")
        print(emp_id)
        return emp_id


if __name__ == '__main__':
    EmpUtil.get_emp_id()